package com.hejia.alauda.persistence.mybatis;

import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import com.hejia.alauda.entity.Invitation;
import com.hejia.alauda.entity.User;
import com.hejia.alauda.persistence.BaseMapper;

public interface InvitationMapper extends BaseMapper<Invitation> {

	@Select("SELECT * FROM `invitation` WHERE `inviter_id`=#{id} and `type`=1 order by createDate desc")
	@ResultMap("ListMap")
	List<Invitation> findInvitationByUser(User user);

	@Select("SELECT count(*) FROM `financing` WHERE `user_id`=#{id}")
	Long countFinancingByUser(User user);

	@Select("SELECT * FROM `invitation` WHERE `invitee_id`=#{id} limit 0,1")
	@ResultMap("DetailMap")
	Invitation findInvitationByInvitee(User user);

	int updateFinancialIncome(Map<String, Object> params);

	int updateFinancialExpired(Map<String, Object> params);

	List<Map<String, Object>> findCreditInvitation(Map<String, Object> params);

	List<Invitation> selectInvitations(Map<String, Object> map);

	int selectInvitationsCount(Map<String, Object> map);
	
	List<Map<String, Object>> findInvitationWithBonus(Map<String, Object> params);
}